/***
 * 行政区工具类
 */

import areaData from '@/libs/area-data-min.js';

export default {

    /**
     * 通过省市区代码获取名称(传的参数顺序不能错)
     * @param {Object} province 省
     * @param {Object} city 市
     * @param {Object} district 区
     * @param {Object} character 间隔符号
     * @returns {string}
     */
    getLabelsByValues(province, city, district, character) {
        character = character ? character : '-';
        let resArr = [];
        let p = areaData.find(f => f.value === province);
        resArr.push(p.label);
        let c = p.children.find(f => f.value === city);
        resArr.push(c.label);
        let d = c.children.find(f => f.value === district);
        resArr.push(d.label);
        return resArr.map(m => m).join(character);
    }
}
